package top.yongyan0624.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.ServletRequestUtils;
import top.yongyan0624.Utils.RedisUtil;
import top.yongyan0624.service.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Yongyan
 * @description
 * @date 2021/5/13
 **/
public class BaseController {

    @Autowired
    HttpServletRequest request;

    @Autowired
    HttpServletResponse response;

    @Autowired
    protected RedisUtil redisUtil;

    @Autowired
    protected CardInfoService cardInfoService;

    @Autowired
    protected CountService countService;

    @Autowired
    protected LeaderService leaderService;

    @Autowired
    protected MessageService messageService;

    @Autowired
    protected NoticeService noticeService;

    @Autowired
    protected QuestionService questionService;

    @Autowired
    protected AnswerService answerService;

    @Autowired
    protected StarService starService;

    @Autowired
    protected TimelineService timelineService;

    @Autowired
    protected SysRoleService sysRoleService;

    @Autowired
    protected SysMenuService sysMenuService;

    @Autowired
    protected SysUserService sysUserService;

    @Autowired
    protected SysUserRoleService sysUserRoleService;

    @Autowired
    protected SysRoleMenuService sysRoleMenuService;

    @Autowired
    protected BCryptPasswordEncoder passwordEncoder;


    /**
     * 获取页面
     * @return page对象
     */
    public <T> Page<T> getPage() {
        int current = ServletRequestUtils.getIntParameter(request, "pageNum", 1);
        int size = ServletRequestUtils.getIntParameter(request, "pageSize", 5);

        return new Page<>(current, size);
    }

}
